﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using QLHXNK.CrystalReport;
using QLHXNK.BusinessLogic;

namespace QLHXNK
{
    public partial class FrmInBaoCao : Form
    {
        public FrmInBaoCao()
        {
            InitializeComponent();
            
        }
        /// <summary>
        /// Báo cáo chi phí
        /// </summary>
        public FrmInBaoCao(String fromMonth, String fromYear, String toMonth, String toYear)
        {
            InitializeComponent();
            this.CenterToScreen();
            //get report source:
            CrystalReportChiPhi report = new CrystalReportChiPhi();
            DataTable table = BaoCao.getExpensesReport(fromMonth, fromYear, toMonth, toYear);
            if (table != null && table.Rows.Count > 0)
                report.SetDataSource(table);

            String thoiGian = "Từ tháng " +  fromMonth + "/" + fromYear + " đến tháng "  + toMonth + "/" + toYear;
            report.SetParameterValue("KhoangThoiGian", thoiGian);

            crystalReportViewer1.ReportSource = report;
        }


        /// <summary>
        /// Báo cáo nhập hàng
        /// </summary>
        public FrmInBaoCao(DateTime fromDate, DateTime toDate, int itemID)
        {
            InitializeComponent();
            this.CenterToScreen();
            //get report source:
            CrystalReportNhapHang report = new CrystalReportNhapHang();
            DataTable table = BaoCao.getImportNoteReport(fromDate, toDate, itemID);
            if (table != null && table.Rows.Count > 0)
                report.SetDataSource(table);

            String thoiGian = "Từ  ngày " + fromDate.Day.ToString() + "/" + fromDate.Month.ToString() + "/" + fromDate.Year.ToString() + "     đến  ngày " + toDate.Day.ToString() + "/" + toDate.Month.ToString() + "/" + toDate.Year.ToString();
            report.SetParameterValue("KhoangThoiGian", thoiGian);

            crystalReportViewer1.DisplayGroupTree = false;
            crystalReportViewer1.ReportSource = report;
        }

        private void FrmInBaoCao_Load(object sender, EventArgs e)
        {

        
        }
        
    }
}